<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
		   <input type="hidden" class="form-control" name="id"  value="${contract.id}"/>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">合同类型：</label>
				<div class="col-sm-4">
					<label class="radio-inline"> 
					   <input value="1" name="type" type="radio" <c:if test="${contract.type eq 1}">checked</c:if>> 新签
					</label> 
					<label class="radio-inline">
                          <input value="2" name="type" type="radio" <c:if test="${contract.type eq 2}">checked</c:if>> 续签
					</label>
				</div>
				<label class="col-sm-2 control-label">合同编号：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="contractNo" name="contractNo"  value="${contract.contractNo}"/>
				</div>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">签约方：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="signing" name="signing" value="${contract.signing}"/>
				</div>
				<label class="col-sm-2 control-label">签约人：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="parties" name="parties" value="${contract.parties}"/>
				</div>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">职位：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="position" name="position" value="${contract.position}"/>
				</div>
				<label class="col-sm-2 control-label">联系电话：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="phone" name="phone" value="${contract.phone}"/>
				</div>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">邮箱：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="email" name="email" value="${contract.email}"/>
				</div>
				<label class="col-sm-2 control-label">合同送达地址：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="address" name="address" value="${contract.address}"/>
				</div>
			</div>
			<div class="form-group form-inline">
				<label class="col-sm-2 control-label">合同开始日期：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="startDate" name="startDate" onClick="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})" placeholder="请选择日期"  readonly="readonly" value="${contract.startDate}"/>
				</div>
				<label class="col-sm-2 control-label">合同结束日期：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="endDate" name="endDate"  onClick="WdatePicker({startDate:'%y-%M-%d',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true,minDate:'#F{$dp.$D(\'startDate\')}'})" placeholder="请选择日期" readonly="readonly" value="${contract.endDate}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">服务费计算基数：</label>
				<div class="col-sm-4 form-inline">
					<select class="form-control" id="cardinalType" name="cardinalType">
					<option value="" >==请选择==</option>
					<option value="1" <c:if test="${contract.cardinalType eq 1 }">selected</c:if>>税前年薪</option>
					<option value="2" <c:if test="${contract.cardinalType eq 2 }">selected</c:if>>税后年薪</option>
					<option value="3" <c:if test="${contract.cardinalType eq 3 }">selected</c:if>>税前月薪</option>
					<option value="4" <c:if test="${contract.cardinalType eq 4 }">selected</c:if>>税前月薪及倍数</option>
					</select>
					<c:if test="${contract.cardinalType eq 1 || contract.cardinalType eq 2 }">
					<input type="text" class="form-control" id="cardinal" name="cardinal" onblur="isInteger('cardinal',this.value)" placeholder="元" value="${contract.cardinal}"/>
					</c:if>
					<c:if test="${contract.cardinalType eq 3 }">
					<input type="text" class="form-control" id="month" name="month" onblur="isInteger('month',this.value)"  placeholder="月" value="${contract.month}"/>
					</c:if>
					<c:if test="${contract.cardinalType eq 4 }">
					<input type="text" class="form-control" id="multiple" name="multiple" onblur="isInteger('multiple',this.value)"  placeholder="倍" value="${contract.multiple}"/>
				    </c:if>
				</div>
				<label class="col-sm-2 control-label">费率：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="rate" name="rate" onblur="isIntDec('rate',this.value)" value="${contract.rate}" placeholder="请输入小数点或整数"/>
				</div>
			</div>
			<div class="form-group">
			    <label class="col-sm-2 control-label">最低付费：</label>
				<div class="col-sm-4 form-inline">
					<input type="text" class="form-control" id="minimumAge" name="minimumAge" onblur="isInteger('minimumAge',this.value)"value="${contract.minimumAge}"/>（元）
				</div>
				<label class="col-sm-2 control-label">付款比例：</label>
				<div class="col-sm-4">
				    预付费金额（元）：<input type="text" class="form-control" id="prepayment" name="prepayment" onblur="isIntDec('prepayment',this.value)" value="${contract.prepayment}"/>
					首款比例：<input type="text" class="form-control" id="firstPayment" name="firstPayment" onblur="isIntDec('firstPayment',this.value)" value="${contract.firstPayment}" placeholder="请输入小数点或整数"/>
					尾款比例：<input type="text" class="form-control" id="finalPayment" name="finalPayment" onblur="isIntDec('finalPayment',this.value)" value="${contract.finalPayment}" placeholder="请输入小数点或整数"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">保障期：</label>
				<div class="col-sm-4">
					<input type="text" class="form-control" id="assure" name="assure" value="${contract.assure}"/>
				</div>
				<label class="col-sm-2 control-label">备注：</label>
				<div class="col-sm-4">
					<textarea class="form-control" id="remark" name="remark" >${contract.remark}</textarea>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
    	$("#cardinalType").change(function(){
    		var num = $(this).val();
    		if(num==1 || num==2){
    			$("#cardinal").show();
    			$("#month").hide();
    			$("#multiple").hide();
    		}else if (num==3) {
    			$("#cardinal").show();
    			$("#month").show();
    			$("#multiple").hide();
			}else if (num==4) {
				$("#cardinal").show();
    			$("#month").show();
    			$("#multiple").show();
			}else {
				$("#cardinal").hide();
    			$("#month").hide();
    			$("#multiple").hide();
			}
    	});
	  $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  new Array('contractNo','合同编号未填写!'),
        	  new Array('signing','签约方未填写!'),
        	  new Array('startDate','合同开始日期未填写!'),
        	  new Array('endDate','合同结束日期未填写!'),
        	  new Array('cardinal','服务费计算基数未填写!'),
        	  new Array('rate','费率未填写!'),
        	  new Array('assure','保障期未填写!'),
        	  new Array('type','合同类型未填写!'),
        	  new Array('parties','签约人未填写!'),
        	  new Array('position','职位未填写!'),
        	  new Array('phone','联系电话未填写!'),
        	  new Array('email','邮箱未填写!'),
        	  new Array('address','合同送达地址未填写!'),
        	  new Array('prepayment','预付费金额未填写!')
        	)
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/contract/update',
                type: 'post',
                dataType: "json",
                beforeSend: function () {
			        // 禁用按钮防止重复提交
					$("#sub").attr("disabled","disabled");
					swal("信息已经提交，请等待后台处理~！");
			    },
				success : function(data) {
					if (data.code == 200) {
						swal({
							title : data.message,
							type : "success",
							showCancelButton : false,
							confirmButtonText : "确定",
							animation : "slide-from-bottom",
							text: "2秒后自动关闭。", 
	      	    			timer: 2000, 
							closeOnConfirm : true
						}, function() {
							top.Dialog.close();
						});
					} else {
						swal("错误", data.message, "error");
					}  
				},    
				complete: function () {
			        $("#sub").removeAttr("disabled");
			    },
			    error: function (data) {
			    	swal("错误", data.message, "error");
			    }
        });
    });
  });  
</script>
</body>
</html>